﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using PlanningGIS.Framework.Rule;

namespace PlanningGIS.DataConvert
{
    /// <summary>
    /// 
    /// </summary>
    public class DataConvert
    {
        /// <summary>
        /// 数据导出规则
        /// </summary>
        [XmlArrayAttribute("DataExportRules")]
        public List<DataExportRule> DataExportRules { get; set; }

        /// <summary>
        /// 数据匹配规则
        /// </summary>
        [XmlArrayAttribute("DataMatchtRules")]
        public List<DataMatchRule> DataMatchtRules { get; set; }

        /// <summary>
        /// 管线入库规则
        /// </summary>
        [XmlArrayAttribute("PipeImportRules")]
        public List<PipeImportRule> PipeImportRules { get; set; }

    }

    #region 数据导出相关规则
    /// <summary>
    /// 
    /// 数据导出规则
    /// </summary>
    [Serializable]
    public class DataExportRule : RuleXml
    {
        /// <summary>
        /// 
        /// </summary>
        [XmlArrayAttribute("导出图层")]
        public List<DataExportLayer> DataExportLayers;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("是否裁切")]
        public bool Cutable;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("是否删除空图层")]
        public bool IsDelNullData;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("导出类型")]
        public string ExportType;

        /// <summary>
        /// 
        /// </summary>
        [XmlElement("空间设置")]
        public SpatialSetting SpatialSetting;
    }

    /// <summary>
    /// 导出图层
    /// </summary>
    [Serializable]
    public class DataExportLayer
    {
        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("图层名称")]
        public string FeatLyrName;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("源要素类名称")]
        public string SourceFeatClsName;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("目标要素类名称")]
        public string TargetFeatClsName;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("属性条件")]
        public string SQL;

    }

    /// <summary>
    /// 空间范围设置
    /// </summary>
    [Serializable]
    public class SpatialSetting
    {
        /// <summary>
        /// 范围类型：0为全图导出；1为按图幅导出；2为按测区导出；3为按行政区导出
        /// </summary>
        [XmlAttribute("范围类型", DataType = "int")]
        public int SpatialType;

        /// <summary>
        /// 
        /// </summary>
        [XmlElement("图幅")]
        public MapsheetInfo MapsheetInfo;

        /// <summary>
        /// 
        /// </summary>
        [XmlElement("测区")]
        public CequInfo CequInfo;

        /// <summary>
        /// 
        /// </summary>
        [XmlElement("行政区")]
        public XzqInfo XzqInfo;
    }

    /// <summary>
    /// 图幅信息
    /// </summary>
    [Serializable]
    public class MapsheetInfo
    {
        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("比例尺")]
        public string Scale;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("是否按图幅拆分")]
        public bool Splitable;

        /// <summary>
        /// 图幅号以分号隔开
        /// </summary>
        [XmlAttribute("图幅号")]
        public string MapNo;
    }

    /// <summary>
    /// 测区信息
    /// </summary>
    [Serializable]
    public class CequInfo
    {
        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("图形")]
        public string Geometry;
    }

    /// <summary>
    /// 行政区信息
    /// </summary>
    [Serializable]
    public class XzqInfo
    {
        /// <summary>
        /// 
        /// </summary>
        [XmlArrayAttribute("行政区")]
        public List<Xzq> Xzqs;
    }

    /// <summary>
    /// 行政区
    /// </summary>
    [Serializable]
    public class Xzq
    {
        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("行政区名称")]
        public string Name;

        /// <summary>
        /// 
        /// </summary>
        [XmlAttribute("行政代码")]
        public string Code;
    }


    #endregion


    /// <summary>
    /// 基础数据按图层入库规则
    /// </summary>
    [Serializable]
    public class DataMatchRule : DataImportRuleBase
    {
        /// <summary>
        /// 目标匹配的要素类集合
        /// </summary>
        [XmlArrayAttribute("DlgTargetMatchFeatureClass")]
        public List<DlgTargetMatchFeatureClass> dlgTargetMatchFeatureClass { get; set; }
    }

}
